//
//  FIRequestCheckVersion.m
//  Magpie
//
//  Created by 100TV protocal on 12-11-14.
//
//

#import "FIRequestCheckVersion.h"
#import "FIHttpAPIHelper.h"
#import "FIStringHelper.h"
#import "SBJson.h"

@implementation FIRequestCheckVersion

-(void) internalInit{
	self.url = urlWithPath(@"/statistics/checkversion");
}

-(id) initWithClientVer:(NSString *) ver clientPlatform:(NSString *)platform source:(NSString *)asource target:(id)atarget action:(SEL)aaction{
	self=[super initWithTarget:atarget action:aaction];
	if(self!=nil){
		[self setParam:ver forKey:@"client_ver"];
		[self setParam:platform forKey:@"client_platform"];
		[self setParam:asource forKey:@"source"];
	}
	return self;
}

-(id) parseResponse:(id)response{
	validResponse(response);
    
    id json = [response JSONValue];
	
	FIYYCheckVersion* ret = [[FIYYCheckVersion alloc] init];
	id version=[json objectForKey:@"success_response"];
	ret.versiontype = [[version objectForKey:@"type"] intValue];
	ret.message =[version objectForKey:@"message"];
	ret.updateurl = [version objectForKey:@"url"];
	return [ret autorelease];
}

@end

@implementation FIYYCheckVersion
-(int) versiontype{
	return [[self attributeForKey:@"versiontype"] intValue];
}
-(void) setVersiontype:(int) aversiontype{
	[self setAttribute:[NSString stringWithFormat:@"%d",aversiontype] forKey:@"versiontype"];
}
-(NSString *)updateurl{
	return [self attributeForKey:@"updateurl"];
}
-(void) setUpdateurl:(NSString *)aupdateurl{
	[self setAttribute:aupdateurl forKey:@"updateurl"];
}
-(NSString *)message{
	return [self attributeForKey:@"message"];
}
-(void) setMessage:(NSString *)amessage{
	[self setAttribute:amessage forKey:@"message"];
}
@end









